package com.paic.custserv.domain;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class UserVO  implements Comparable<UserVO>,Serializable{

	private static final long serialVersionUID = 1232809404715026803L;
	//用户账号
    private String userUMID;
    //用户名
    private String userName;
    //密码
    private String password;
    //用户创建时间
    public Date createTime;
    //用户角色
    public String userRole;
        
    public UserVO(){}
    
    public UserVO(String userUMID){
    	this.userUMID=userUMID;
    }
    
    public UserVO(String userUMID,String userName){
    	this.userUMID=userUMID;
    	this.userName=userName;
    }
    
    public UserVO(String userUMID,String userName,Date createTime){
    	this.userUMID=userUMID;
    	this.userName=userName;
    	this.createTime=createTime;
    }   
    
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUserUMID() {
		return userUMID;
	}
	public void setUserUMID(String userUMID) {
		this.userUMID = userUMID;
	}		
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getUserRole() {
		return userRole;
	}
	public void setUserRole(String userRole) {
		this.userRole = userRole;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((userUMID == null) ? 0 : userUMID.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserVO other = (UserVO) obj;
		if (userUMID == null) {
			if (other.userUMID != null)
				return false;
		} else if (!userUMID.equals(other.userUMID))
			return false;
		return true;
	}

	//按时间从远到近
	@Override
	public int compareTo(UserVO obj) {
		Long commentTimeFirst=this.getCreateTime().getTime();
		Long commentTimeSecond=obj.getCreateTime().getTime();
		Long diff=commentTimeFirst-commentTimeSecond;
		return diff>0?1:(diff==0?0:-1);
	}  
	
	
	public static void main(String str[]) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		UserVO uservo2=new UserVO();
		uservo2.setCreateTime(new Date());
		UserVO uservo1=new UserVO();
		Date dt=format.parse("2014-10-20 12:13:30");
		uservo1.setCreateTime(dt);
	}
}
